using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Umdf.SideShow.Contents
{
    public class GlanceContent : Content
    {
        private string _text;

        public GlanceContent(BinaryReader reader)
        {
            DeserializeObject(reader);
        }

        public GlanceContent(string text)
            : base(0)
        {
            _text = text;
        }

        public string Text
        {
            get { return _text; }
        }

        public override void Save(string dir)
        {
            string fileName = Path.Combine(dir, Id.ToString() + ".txt");
            File.WriteAllText(fileName, _text);
        }

        protected internal override void SerializeObject(BinaryWriter writer)
        {
            base.SerializeObject(writer);
            writer.Write(_text);
        }

        protected internal override void DeserializeObject(BinaryReader reader)
        {
            base.DeserializeObject(reader);
            _text = reader.ReadString();            
        }
    }
}
